﻿using MediatR;
using Microsoft.EntityFrameworkCore;
using RearLivestock.Common.Domains.hq;
using RearLivestock.Common.Dtos;
using RearLivestock.Common.Infrastructure.Interface;
using RearLivestock.RBAC.ErrorCodeEnum;

namespace RearLivestock.RBAC.Api.Application.hqApplication.Commands.Ablactationss
{
    public class GetBedRoomHnader : IRequestHandler<GetBrdRoomComand, Result>
    {
        private readonly IBaseRepository<BedroomTypes> bedroomTypesRepository;

        public GetBedRoomHnader(IBaseRepository<BedroomTypes> bedroomTypesRepository)
        {
            this.bedroomTypesRepository = bedroomTypesRepository;
        }
        /// <summary>
        /// 转舍
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Result> Handle(GetBrdRoomComand request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = (int)CommonErrorCode.Search };
            var res = await (await bedroomTypesRepository.GetAll()).ToListAsync();
            if (res != null)
            {
                result.Data = res;
                result.Code = (int)CommonErrorCode.Success;
            }
            return result;
        }
    }
}
